prefix          := @prefix@
abs_top_src_dir := @abs_top_srcdir@
instbasedir     := $(DESTDIR)$(prefix)
bmarkdir        := $(abs_top_src_dir)/benchmarks
isa_src_dir     := $(abs_top_src_dir)/isa

all: benchmarks isa

install: all
	install -d $(instbasedir)/share/riscv-tests/isa
	install -d $(instbasedir)/share/riscv-tests/benchmarks
	install -p -m 644 `find isa -maxdepth 1 -type f` $(instbasedir)/share/riscv-tests/isa
	install -p -m 644 `find benchmarks -maxdepth 1 -type f` $(instbasedir)/share/riscv-tests/benchmarks

benchmarks:
	mkdir -p benchmarks
	$(MAKE) -C benchmarks -f $(bmarkdir)/Makefile src_dir=$(bmarkdir)

isa:
	mkdir -p isa
	$(MAKE) -C isa -f $(isa_src_dir)/Makefile src_dir=$(isa_src_dir)

clean:
	$(MAKE) -C isa -f $(isa_src_dir)/Makefile src_dir=$(isa_src_dir) clean
	$(MAKE) -C benchmarks -f $(bmarkdir)/Makefile src_dir=$(bmarkdir) clean

.PHONY: benchmarks isa clean

